<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录注册页面</title>
    <!-- 引入 Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入 jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- 引入 Bootstrap JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="row justify-content-center align-items-center min-vh-100">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header text-center">
                        <ul class="nav nav-tabs card-header-tabs">
                            <li class="nav-item">
                                <a class="nav-link active" href="#login" data-bs-toggle="tab">登录</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="#register" data-bs-toggle="tab">注册</a>
                            </li>
                        </ul>
                    </div>
                    <div class="card-body">
                        <div class="tab-content">
                            <div class="tab-pane fade show active" id="login">
                                <form id="loginForm">
                                    <div class="mb-3">
                                        <label for="loginEmail" class="form-label">邮箱地址</label>
                                        <input type="email" class="form-control" id="loginEmail" required>
                                    </div>
                                    <div class="mb-3">
                                        <label for="loginPassword" class="form-label">密码</label>
                                        <input type="password" class="form-control" id="loginPassword" required>
                                    </div>
                                    <button type="submit" class="btn btn-primary w-100">登录</button>
                                </form>
                            </div>
                            <div class="tab-pane fade" id="register">
                                <form id="registerForm">
                                    <div class="mb-3">
                                        <label for="registerEmail" class="form-label">邮箱地址</label>
                                        <input type="email" class="form-control" id="registerEmail" required>
                                    </div>
                                    <div class="mb-3">
                                        <label for="registerPassword" class="form-label">密码</label>
                                        <input type="password" class="form-control" id="registerPassword" required>
                                    </div>
                                    <div class="mb-3">
                                        <label for="confirmPassword" class="form-label">确认密码</label>
                                        <input type="password" class="form-control" id="confirmPassword" required>
                                    </div>
                                    <button type="submit" class="btn btn-primary w-100">注册</button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function() {
            // 登录表单提交事件
            $("#loginForm").submit(function(event) {
                event.preventDefault(); // 阻止默认提交行为
                var email = $("#loginEmail").val();
                var password = $("#loginPassword").val();
                // TODO: 发送登录请求到服务器验证用户身份
                console.log("登录信息：", email, password);
            });

            // 注册表单提交事件
            $("#registerForm").submit(function(event) {
                event.preventDefault(); // 阻止默认提交行为
                var email = $("#registerEmail").val();
                var password = $("#registerPassword").val();
                var confirmPassword = $("#confirmPassword").val();
                if (password !== confirmPassword) {
                    alert("两次输入的密码不一致，请重新输入！");
                    return;
                }
                // TODO: 发送注册请求到服务器创建新用户
                console.log("注册信息：", email, password);
            });
        });
    </script>
</body>
</html>
